<template>
  <div>
    <swiper :options="swiperOption" class="swiper" v-if="showSwiper">
      <!-- slides -->
      <swiper-slide v-for="item of swiperList" :key="item.id">
        <img :src="item.imgUrl" alt />
      </swiper-slide>
      <!-- Optional controls -->
      <div class="swiper-pagination" slot="pagination"></div>
    </swiper>
  </div>
</template>

<script>
export default {
  name: "mainSwiper",
  props: {
    swiperList: Array
  },
  data() {
    return {
      swiperOption: {
        pagination: ".swiper-pagination",
        paginationClickable: true,
        autoplay: 3000,
        loop: true
      }
    };
  },
  computed: {
    showSwiper () {
      return this.swiperList.length
    }
  }
};
</script>

<style lang="stylus" scoped>
img {
  width: 100%;
  height: 2.88rem;
}

width 100%, .swiper {
  height: 0;
  overflow: hidden;
  width: 100%;
}
</style>